﻿@inject IStringLocalizer<Foo> LocalizerFoo

<div>
    <FormInlineSwitch @bind-Value="@FormRowType" class="mb-3"></FormInlineSwitch>
    <ValidateForm Model="@Model">
        <div class="@GroupFormClassString">
            <div class="col-12 col-sm-6">
                <BootstrapInputGroupLabel @bind-Value="@Model.Name" required="true" />
                <BootstrapInputGroup>
                    <Display @bind-Value="@Model.Name"></Display>
                    <BootstrapInputGroupLabel @bind-Value="@Model.Name" />
                </BootstrapInputGroup>
            </div>
            <div class="col-12 col-sm-6">
                <BootstrapInputGroupLabel @bind-Value="@Model.Address" required="true" />
                <BootstrapInputGroup>
                    <Display @bind-Value="@Model.Address"></Display>
                    <BootstrapInputGroupLabel @bind-Value="@Model.Address" />
                </BootstrapInputGroup>
            </div>
        </div>
    </ValidateForm>
</div>

@code {
    /// <summary>
    /// Foo 类为Demo测试用，如有需要请自行下载源码查阅
    /// Foo class is used for Demo test, please download the source code if necessary
    /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
    /// </summary>
    [NotNull]
    private Foo? Model { get; set; }

    private string? GroupFormClassString => CssBuilder.Default("row g-3")
        .AddClass("form-inline", FormRowType == RowType.Inline)
        .Build();

    private RowType FormRowType { get; set; }

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override void OnInitialized()
    {
        Model = Foo.Generate(LocalizerFoo);
    }
}
